import RobotError from "../errors/robot-error.js";
import { Fighter } from "../player/ability.js";
import FightM from "../player/member/fight.js";
import Player from "../player/player.js";
import Item from "./item.js";
import Prop from "./prop.js";




/**还魂丹 复活用 */
export default class InvisibleMedicine extends Prop {
	intro: string = "使用后的第一次攻击不会被闪避，可用于隐身打劫";

	constructor() {
		super("隐身水");
	}

	use(user: Player): { msg: string; } {
		user.fightMember = new IFightM(user);
		return {
			msg: `成功服用隐身水`
		};
	}
}

class IFightM extends FightM {
	/**攻击，不会被闪避 */
	hit(target: Fighter) {
		let status = {
			damage: 0,
			success: false,
			dodgeSuccess: true
		};

		let hurtResult = this.hurt(target);
		status = {
			damage: hurtResult.damage,
			success: hurtResult.success,
			dodgeSuccess: false
		};

		(<Player>this.host).fightMember = new FightM(this.host);

		return status;
	}


}

